<?php

$di     = \application\units\Di::getInstance();
$params = [
    'id'       => $di->request->params('id'),
    'admin_id' => $di->auth->id,
];

$where     = 'id=:id';
$bindValue = [
    'id' => $params['id'],
];

if ($params['admin_id']) {
    $adminIds              = $di->auth->getChildrenRoleAdminIds($params['admin_id'], true);
    $where                 .= ' and admin_id in (:admin_id)';
    $bindValue['admin_id'] = $adminIds;
}

$row = $di->db->find(sprintf('select * from admin_operation_log where %s', $where), $bindValue);

if (!$row) {
    throw new LogicException('未找到记录');
}

return [
    'row' => $row,
];
